<?php

declare(strict_types=1);

namespace app\common\model;

use think\Model;
use think\model\concern\SoftDelete;
use think\facade\Db;

class ChoujiangGoodsconfig extends Model
{
    use SoftDelete;
    protected $deleteTime = "delete_time";
    // 获取列表
    public static function getList()
    {
        $where = [];
        $limit = input('get.limit');

        //按第三方物品名称查找
        if ($ohername = input("ohername")) {
            $where[] = ["ohername", "like", "%" . $ohername . "%"];
        }
        //按物品id查找
        if ($goodsid = input("goodsid")) {
            $where[] = ["goodsid", "like", "%" . $goodsid . "%"];
        }
        //按物品名称查找
        if ($goodsname = input("goodsname")) {
            $where[] = ["goodsname", "like", "%" . $goodsname . "%"];
        }
        //按物品数量查找
        if ($goodsnum = input("goodsnum")) {
            $where[] = ["goodsnum", "like", "%" . $goodsnum . "%"];
        }
        $list = self::order('id', 'desc')->where($where)->paginate($limit);
        return ['code' => 0, 'data' => $list->items(), 'extend' => ['count' => $list->total(), 'limit' => $limit]];
    }




    public static function getGoods($goodsname)
    {
        return Db::query("select * from choujiang_goodsconfig where ohername='$goodsname';")[0];
    }
}
